package com.sgcc.sx.pmos.e_sx_mall.adapter;


import android.content.Context;
import android.graphics.Color;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.sx.pmos.e_sx_mall.bean.GoodSortBean;

public class GoodSortAdapter extends BaseQuickAdapter<GoodSortBean, BaseViewHolder> {
    int lastPostion=0;
    public GoodSortAdapter(Context context) {
        super(R.layout.item_goods_sort);
    }

    public interface OnItemClickListener {
        //条目点击
        void OnItemsClickListener(int position, String text,int lastPostion);
    }

    private OnItemClickListener mOnItemClickListener;

    public void setItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, GoodSortBean s) {
        baseViewHolder.setText(R.id.txt_name, s.getName());
        if(s.isSelect()){
            baseViewHolder.setTextColor(R.id.txt_name, Color.parseColor("#0092FF"));
        }else{
            baseViewHolder.setTextColor(R.id.txt_name, Color.parseColor("#999999"));
        }
        baseViewHolder.getView(R.id.liner_parent).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (mOnItemClickListener != null) {
                    mOnItemClickListener.OnItemsClickListener(getItemPosition(s), s.getName(),lastPostion);
                }
                lastPostion = getItemPosition(s);
            }
        });
    }



}
